/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import javax.sip.header.ProxyRequireHeader;
import java.text.ParseException;

/**
 * The Proxy-Require header field is used to indicate proxy-sensitive features
 * that must be supported by the proxy. The Proxy-Require header field contains
 * a list of option tags. Each option tag defines a SIP extension that MUST be
 * understood by the proxy to process the request. Any ProxyRequireHeader
 * features that are not supported by the proxy must be negatively acknowledged
 * by the proxy to the client if not supported. Proxy servers treat this field
 * identically to the RequireHeader.
 * <p/>
 * For Example:<br>
 * <code>Proxy-Require: foo</code>
 *
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 * @see javax.sip.header.RequireHeader
 */
public class ProxyRequireHeaderImpl extends HeaderBase implements ProxyRequireHeader {
    private String optionTag;

    private static final ProxyRequireHeaderParser parser = new ProxyRequireHeaderParser();

    public ProxyRequireHeaderImpl() {
        super(ProxyRequireHeader.NAME);
    }

    public ProxyRequireHeaderImpl(byte[] data, int start, int end) {
        super(ProxyRequireHeader.NAME, data, start, end);
    }

    public Object clone() {
        final ProxyRequireHeaderImpl header = new ProxyRequireHeaderImpl();
        header.cloneBase(this);
        if (parsed) {
            header.optionTag = this.optionTag;
        }
        return header;
    }

    protected HeaderParser getParser() {
        return parser;
    }

    protected String getValueAsString() {
        return optionTag;
    }

    /**
     * Sets the option tag value to the new supplied optionTag
     * parameter.
     *
     * @param optionTag the new string value of the option tag.
     * @throws java.text.ParseException which signals that an error has been reached
     *                                  unexpectedly while parsing the optionTag value.
     */
    public void setOptionTag(String optionTag) throws ParseException {
        parse();
        this.optionTag = optionTag;
        invalidateHeaderData();
    }

    /**
     * Gets the option tag of this OptionTag class.
     *
     * @return the string that identifies the option tag value.
     */
    public String getOptionTag() {
        parse();
        return this.optionTag;
    }
}
/*
 * $Log$
 */